classdef MultiLabelDimensionalityReductionViaDependenceMaximization ...
        < MultiLabelAlgorithm ...
        & FeatureSubsetSizeable ...
        & Modelable
    %MULTILABELDIMENSIONALITYREDUCTIONVIADEPENDENCEMAXIMIZATION Summary of this class goes here
    %   Detailed explanation goes here
    
    properties (SetAccess = protected )
        projectionType = 'proj' % {'proj':uncorrelated projection dim reduction, 'spc': uncorrelated subspace dim reduction}
        mu = 0 % Regularization parameter
    end
    
    methods
        function [  ] = setProjectionType( this, projectionType )
            if nargin == 1
                this.projectionType = 'proj';
            end
            if nargin == 2
                this.projectionType = projectionType;
            end
        end
        
        function setMu( this, mu )
            if nargin == 1
                this.mu = 0;
            end
            if nargin == 2
                this.mu = mu;
            end
        end
    end
    
    methods
        function [ this ] = MultiLabelDimensionalityReductionViaDependenceMaximization(  )
            if nargin == 0
                this.setName('mddm');
            end
        end
    end
    
    methods
        function [  ] = build( this, X1, Y1 )
            if isequal(this.projectionType, 'spc')
                this.model.meanX = mean(X1, 1);
                X1 = bsxfun(@minus, X1, this.model.meanX);
            end
            L1 = Y1*(Y1');
            kFeature = this.calcFeatureSubsetSizeOn(X1);
            [this.model.XL, this.model.zWeight] = mddm_linear(X1', L1, this.projectionType, this.mu, kFeature);
        end
        
        function [ result ] = apply( this, X2, Y2 )
            if isequal(this.projectionType, 'spc')
                X2 = bsxfun(@minus, X2, this.model.meanX);
            end
            result = X2*this.model.XL;
        end
    end
    
end

